﻿using System;
//using System.Collections.Generic;
//using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using Yang.DataBase;


public partial class getData : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "text/xml";
        Response.Charset = "utf-8";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");

        string ProductType = "";                //成果类型
        int pageIndex = 1;
        int rowsIndex = 1;

        ProductType = Request.QueryString[0].ToString();
        rowsIndex = Int32.Parse(Request.QueryString[1].ToString());
        pageIndex = Int32.Parse(Request.QueryString[2].ToString());

        ProductType = Utility.ProductId2Name(ProductType);

        string strSQL = "select * from " + ProductType + " Order by 编号";
        DataSet ds = Database.Query(strSQL);


        string resultXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "\n";
        resultXml += "<ResultList>" + "\n";
        
        if (ds.Tables[0].Rows.Count > 0)
        {
            string[] results = new string[ds.Tables[0].Columns.Count];
            resultXml += "<Result ";
            for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
            {
                resultXml += ds.Tables[0].Columns[i].ColumnName + " = '" + Utility.ReplaceXMLESC(ds.Tables[0].Rows[(pageIndex-1) * 10 + rowsIndex][i].ToString()) + "' ";
            }

            //for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            //{
            //    resultXml += ds.Tables[0].Columns[i].ColumnName + " = '" + Utility.ReplaceXMLESC(dt.Rows[i][j].ToString().Trim()) + "' ";
            //}
            resultXml += " />" + "\n";
            resultXml += "</ResultList>";

            Response.Write(resultXml);
        
        }
        





    }
}
